package com.weixing.mall.provider.controller.admin;

import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.annotation.NoRepeatSubmit;
import com.weixing.mall.core.support.auth.MemAuth;
import com.weixing.mall.core.support.auth.MemInfo;
import com.weixing.mall.core.support.auth.SysAuth;
import com.weixing.mall.core.support.auth.SysInfo;
import com.weixing.mall.provider.model.dto.AfterSaleOperationDto;
import com.weixing.mall.provider.model.dto.CustomerOperationDto;
import com.weixing.mall.provider.model.query.AfterSaleOperationQuery;
import com.weixing.mall.provider.model.vo.AfterSaleOperationVo;
import com.weixing.mall.provider.service.IAfterSaleOperationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName AdminAfterSaleOperationController
 * @Description TODO <br/>
 * @Author gjq
 * @Modified By:
 * @Date 2019/10/15
 * @Version 1.0
 **/
@RestController
@RequestMapping("afterSaleOperation")
@Api(value = "后台售后操作记录APi", tags = "后台售后操作记录")
public class AfterSaleOperationController {

    @Autowired
    private IAfterSaleOperationService afterSaleOperationService;

    @ApiOperation(value = "加载售后操作列表")
    @GetMapping("getOrderOperation")
    public Result getOrderList(AfterSaleOperationQuery afterSaleOperationQuery) {
        List<AfterSaleOperationVo> list = afterSaleOperationService.selectList(afterSaleOperationQuery);
        return ResultUtil.success(list);
    }

    @ApiOperation(value = "保存售后操作")
    @PostMapping("save")
    @NoRepeatSubmit
    public Result save(@SysInfo SysAuth auth, @Validated AfterSaleOperationDto afterSaleOperationDto) {
        afterSaleOperationService.save(afterSaleOperationDto,auth.getUid());
        return ResultUtil.success();
    }

    @ApiOperation(value = "客服保存售后操作")
    @PostMapping("saveCustomer")
    @NoRepeatSubmit
    public Result saveCustomer(@Validated CustomerOperationDto customerOperationDto,@SysInfo SysAuth auth) {
        afterSaleOperationService.saveCustomer(customerOperationDto,auth);
        return ResultUtil.success();
    }

    @ApiOperation(value = "售后操作时间发展")
    @GetMapping("developmentTime/{afterSaleId}")
    public Result developmentTime(@PathVariable Long afterSaleId){
        return ResultUtil.success(afterSaleOperationService.developmentTime(afterSaleId));
    }

    @ApiOperation(value = "客服售后操作时间发展")
    @GetMapping("customerDevelopmentTime")
    public Result customerDevelopmentTime(Long afterSaleId){
        return ResultUtil.success(afterSaleOperationService.customerDevelopmentTime(afterSaleId));
    }
}
